#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> coins(n);
  for (auto& x: coins) cin >> x;
  long long a = 0, b = 0;
  auto getCoin = [&](long long &sum) {
    int index = -1;
    int mini = 0;
    for (int i = 0; i < coins.size(); i ++) {
      if (coins[i] <= sum) {
        if (index == -1 || coins[i] > coins[index]) {
          index = i;
        }
      }
      if (coins[i] < coins[mini]) {
        mini = i;
      }
    }
    if (index == -1) index = mini;
    sum += coins[index];
    coins.erase(coins.begin() + index);
  };
  
  while (!coins.empty()) {
    getCoin(a);
    if (coins.empty()) break;
    getCoin(b);
  }
  cout << a << ' ' << b << endl;
}